import inspect


class ClassAgent(object):
    def __str__(self):
        return self.class_name

    def __init__(self, class_name):
        self.class_name = class_name
        # name: module.path.filename.classname
        self.parents_name_list = []
        # seems don't need this one
        #self.parents_agent_list = []

        # method: classname.methodname
        self.method_list = []
        #self.method_agent_list = []
        self.attr_list = []

    def getName(self):
        return self.class_name

    def getParentName(self):
        return self.parents_name_list

    def getMethod(self):
        return self.method_list

    def getAttr(self):
        return self.attr_list

    #def getPaentAgent(self):
        #return self.parents_agent_list

class MethodAgent(object):
    """
    """
    def __init__(self, method_obj):
        self.method_obj = method_obj
        self._generate()

    def _generate(self):
        self.method_name = self.method_obj.im_func.func_name.replace('<', '').replace('>', '')
        # hard to believe the result is changed.. 
        #self.args = inspect.getargs(self.method_obj.im_func.func_code).args
        self.args = inspect.getargs(self.method_obj.im_func.func_code)[0]

    def getName(self):
        return self.method_name

    def getParam(self):
        return self.args


class AttrAgent(object):
    """
    """
    def __init__(self, attr_name, attr):
        self.attr_name = attr_name.replace('<', '').replace('>', '')
        self.attr = attr
        self._generate()

    def _generate(self):
        self.attr_type = str(type(self.attr)).replace('<', '').replace('>', '')

    def getName(self):
        return self.attr_name

    def getType(self):
        return self.attr_type

